package com.flitsneak.designpatterns.structuralpatterns.adapter.interfaceadapter;

import com.flitsneak.designpatterns.structuralpatterns.adapter.interfaceadapter.adapter.DanceAdapter;
import com.flitsneak.designpatterns.structuralpatterns.adapter.interfaceadapter.adapter.PlayAdapter;
import com.flitsneak.designpatterns.structuralpatterns.adapter.interfaceadapter.adapter.SingAdapter;

/**
 * @author flitsneak
 * @email flitsneak@gmail.com
 * @date 2022/7/12 11:01
 * @description
 */
public class SimpFeiFeiAdapter implements SimpFeiFei{
    @Override
    public void playGames() {
        processSpecialty(PlayAdapter.class);
    }

    @Override
    public void singJayZhou() {
        processSpecialty(SingAdapter.class);
    }

    @Override
    public void danceLocker() {
        processSpecialty(DanceAdapter.class);
    }

    private void processSpecialty(Class<? extends Specialty> clazz){
        try {
            Specialty adapter = clazz.newInstance();
            adapter.showSpecialty();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
